
class Singleton2{
    //让类的实例为null
   private static Singleton2 instance = null ;
   //一个静态方法里,如果第一次调用才创建类的实例
   public static synchronized  Singleton2 getInstance(){
      if(instance == null){
          synchronized(Singleton2.class){
              if(instance == null){
                  instance = new Singleton2();
              }
          }  
      }
       return instance;
   }
   private Singleton2(){};

}



public class Test3 {
    public static void main(String[] args) {

    }
}
